package com.china08.yxyapi.api.manage.sch.platform.statistics.resource;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.service.manage.edu.platform.statistics.StatisticsSchoolService;

import io.swagger.annotations.ApiOperation;

/**
 * 教育局平台办公 数据统计学校 资源统计 资源统计统计
 * 
 */
@CrossOrigin
@RestController
public class ResourceStaticCountController extends YxyApiBaseController {
	@Autowired
	private StatisticsSchoolService statisticsSchoolService;

	@ApiOperation(value = "数据统计学校      数据总览     资源数据总览    资源")
	@ResponseBody
	@RequestMapping(value = "/api_yw/manage/sch/platform/statistics/resource/resourceallcount/srh", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public RespModel precess(HttpServletRequest request, HttpServletResponse response) {
		RespModel model = new RespModel();
		String school = getProfile(request, response).getSchoolId();

		StatisticsResourceModel statisticsResourceModel = new StatisticsResourceModel();

		// 调用此方法查询资源数据总览数据
		List<Long> countLst = statisticsSchoolService.statisticsResourceCount(school);
		statisticsResourceModel.resourceCount = countLst.get(0);
		statisticsResourceModel.nearResourceCount = countLst.get(2);

		// 调用此方法查询微课数据总览数据
		List<Long> countLst1 = statisticsSchoolService.statisticsWeikeCount(school);
		statisticsResourceModel.weikeCount = countLst1.get(0);
		statisticsResourceModel.nearWeikeCount = countLst1.get(2);
		model.statisticsResourceModel = statisticsResourceModel;
		return model;
	}

	protected static class RespModel extends YxyApiRespModel {

		// 统计资源数据总览模型
		public StatisticsResourceModel statisticsResourceModel;
	}

	/**
	 * 统计资源数据总览模型
	 */
	protected class StatisticsResourceModel {
		// 资源总数量
		public Long resourceCount;
		// 最近新增资源
		public Long nearResourceCount;
		// 微课总数量
		public Long weikeCount;
		// 最近新增资源
		public Long nearWeikeCount;
	}
}
